package qsoft.omanga.ui.custom;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import qsoft.omanga.business.entities.Manga;
import qsoft.omanga.common.utils.FileUtil;
import qsoft.omanga.common.utils.Loading;
import qsoft.omanga.ui.R;

public class GalleryMangaHolder {
	/**
     * 
     */
	private Context context;
	/**
     * 
     */
	private ImageView ivImage;
	/**
     * 
     */
	private Manga item;
	/**
     * 
     */
	private LayoutInflater inflater;

	/**
	 * @param ctx
	 *            Context
	 * @param item
	 *            Manga
	 */
	public GalleryMangaHolder(Context ctx, Manga item) {
		this.context = ctx;
		this.item = item;
	}

	/**
	 * @param convertView
	 *            View
	 * @return View
	 */
	public View getRow(View convertView) {
		View row = convertView;
		if (row == null) {
			inflater = LayoutInflater.from(context);
			row = inflater.inflate(R.layout.item_image_manga, null);
			ivImage = (ImageView) row.findViewById(R.id.itemGallery_mangaImage);
			row.setTag(this);
		}
		GalleryMangaHolder galleryHolder = (GalleryMangaHolder) row.getTag();
		galleryHolder.ivImage.setTag(item.getPicLarge());
		Loading.getInstance().forceLoad(galleryHolder.ivImage, item.getId(),
				item.getPicLarge(), FileUtil.IMAGE_LARGE);
		// QueueLoad.getInstance().forceLoad(rkMangaHolder.ivImage,
		// item.getId(),
		// item.getPicLarge(), FileUtil.IMAGE_LARGE);
		// AsyncLoad.getInstance().load(item.getPicLarge(),
		// rkMangaHolder.ivImage);
		return row;
	}
}
